Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #200

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Solution #200

wants to merge 2 commits into from

Conversation

Kalixone
Copy link

No description provided.

Copy link

@George-Khomiak George-Khomiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add DTOs for your responses and a mapper if needed and we are good:)

return characterService.getRandomCharacter();
}

@GetMapping("/search")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GetMapping
REST is rather resource oriented

@GetMapping("/random")
@Operation(summary = "Get a random character",
description = "Returns a random character from the database.")
public Optional<Character> getRandomCharacter() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Controllers should work with DTO objects, not with model. Create a response DTO for this endpoint

@GetMapping("/search")
@Operation(summary = "Search characters by name",
description = "Returns a list of characters whose name contains the specified word.")
public List<Character> searchCharactersByName(@RequestParam String word) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, return list of DTO responses


@Getter
@Setter
public class RickAndMortyResponse {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class name is just the name of whole app, it's not clear why RickAndMorty fetches all characters, it's more like CharacterListDto or something like that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants